// 相加的浮点数
export const add = (num1, num2) => {
	const num1Digits = (num1.toString().split('.')[1] || '').length;
	const num2Digits = (num2.toString().split('.')[1] || '').length;
	const baseNum = Math.pow(10, Math.max(num1Digits, num2Digits));
	return (num1 * baseNum + num2 * baseNum) / baseNum;
}

// 相乘的浮点数
export const accMul = (arg1, arg2) => {
	var m = 0,
		s1 = arg1.toString(),
		s2 = arg2.toString();
	try {
		if (s1.split(".")[1] != undefined)
			m += s1.split(".")[1].length
	} catch (e) {}
	try {
		if (s2.split(".")[1] != undefined)
			m += s2.split(".")[1].length
	} catch (e) {}
	return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
}

// 相除的浮点数
export const accDiv = (arg1, arg2) => {
	var r1 = 0,
		r2 = 0,
		m, s1 = arg1.toString(),
		s2 = arg2.toString();
	try {
		if (s1.split(".")[1] != undefined)
			r1 = s1.split(".")[1].length;
	} catch (e) {}
	try {
		if (s2.split(".")[1] != undefined)
			r2 = s2.split(".")[1].length;
	} catch (e) {}
	m = Math.pow(10, Math.max(r1, r2));
	return (accMul(arg1, m)) / (accMul(arg2, m));
}
// 相减的浮点数
export const accSubtr = (num1, num2) => {
	const num1Digits = (num1.toString().split('.')[1] || '').length;
	const num2Digits = (num2.toString().split('.')[1] || '').length;
	const baseNum = Math.pow(10, Math.max(num1Digits, num2Digits));
	return (num1 * baseNum + -(num2 * baseNum)) / baseNum;
}
